﻿/**************************************************************
 * Project     : Titan Framework
 * Copyright (C) 2011 Microsoft Corp.
 * Author      : Julian Hu
 * Mail        : junhu@microsoft.com
 * Create Date : 2011-05-16
 * Summary     :   
 * 
 * 
 * Modified By : 
 * Date        : 
 * Mail        : 
 * Comment     :   
 * *************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Titan.Data
{
    public abstract class DataEntityBase:ICloneable
    {
        //public abstract DataEntityBase Clone();

        public string getLoggingInfo()
        {
            string result = "";
            Type t = this.GetType();
            PropertyInfo[] properties = t.GetProperties(BindingFlags.Public|BindingFlags.Instance);
            foreach (PropertyInfo property in properties)
            {
                if (result.Equals(""))
                {
                    result = String.Format("{0}={1}", property.Name, property.GetValue(this, null));
                }
                else
                {
                    result = String.Format("{0};{1}={2}", result, property.Name, property.GetValue(this, null));
                }
            }

            FieldInfo[] fields = t.GetFields(BindingFlags.Public | BindingFlags.Instance);
            foreach (FieldInfo field in fields)
            {
                if (result.Equals(""))
                {
                    result = String.Format("{0}={1}", field.Name, field.GetValue(this));
                }
                else
                {
                    result = String.Format("{0};{1}={2}", result, field.Name, field.GetValue(this));
                }
            }
            return result;
        }
        public object Clone()
        {
            throw new NotImplementedException();
        }
    }
}
